Add xstrrstr for searching strings from back. Make geo use it.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 13 Sep 2005 06:19:24 +0000 (06:19 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 13 Sep 2005 06:19:24 +0000 (06:19 +0000)
gpsbabel/defs.h
gpsbabel/geo.c
gpsbabel/util.c

index 32a9935ac3aedacc3fa091ef6c8f4873fc48d5f1..2dced8f30998a6e9b1adef5e0b2f2dd91097339b 100644 (file)
@@ -593,6 +593,7 @@ int case_ignore_strncmp(const char *s1, const char *s2, int n);
 
 char *strsub(const char *s, const char *search, const char *replace);
 char *gstrsub(const char *s, const char *search, const char *replace);
+char *xstrrstr(const char *s1, const char *s2);
 void rtrim(char *s);
 signed int get_tz_offset(void);
 time_t mkgmtime(struct tm *t);
index 4ce36d04e75d03503c7cb0e9822be58dfe0d224a..c1f4fc96aee363283b82c3b3671dfc8869889fb2 100644 (file)
@@ -95,7 +95,7 @@ void wpt_name(const char *args, const char **unused)
 
        wpt_tmp->description = xstrappend(wpt_tmp->description,args);
        if (nuke_placer) {
-               char *s = strstr(wpt_tmp->description, " by ");
+               char *s = xstrrstr(wpt_tmp->description, " by ");
                if (s) {
                        *s = '\0';
                }
index 03bffb33101b6be232a7e530cea3c0b55733ab5b..ad4edf43998056958ab40f04d7e4be98032d74cf 100644 (file)
@@ -727,6 +727,22 @@ gstrsub(const char *s, const char *search, const char *replace)
        return o;
 }
 
+/*
+ * Like strstr, but starts from back of string.
+ */
+char *
+xstrrstr(const char *s1, const char *s2) 
+{
+       char *r = NULL, *next = NULL; 
+
+       while (next = strstr(s1, s2)) {
+               r = next;
+               s1 = next + 1;
+       }
+       return r;
+}
+
+
 char *
 rot13( const char *s )
 {